<?php

namespace app\common\controller;
use think\Db;
use fast\Random;
use think\Log;

/**
 * API控制器基类
 */
class Callfunc
{


    /**
     * 获取序列号
     * @param string $name
     */
    static public function makeUuid()
    {
        $first = rand(10, 99);
        $second = substr(date(strtotime("now")), -5);
        $third = Random::numeric(2);
        $uuid = sprintf("%s%s%s", $first, $second, $third);
        return $uuid;
    }

    static public function getCompanyUsers($company_id='')
    {
        $allUsers = [];
        if ($company_id){
            $companyUsers = Db::query("select id from admin where company_id=?", [$company_id]);
            foreach ($companyUsers as $row) {
                $allUsers[] = $row['id'];
            }
            return $allUsers;
        }
        return $allUsers;
    }

    /**
     * 获取图片高度
     */
    static public function get_image_height($image)
    {
        if ($image) {
            $image_info = getimagesize($_SERVER['DOCUMENT_ROOT'] . $image);
            $height = $image_info[1];
        } else {
            $height = 0;
        }
        return $height;
    }

}
